home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_plotutils.idb / usr / freeware / share / libplot / h-demo.c.z / h-demo.c
Encoding:
C/C++ Source or Header  |  1998-10-28  |  6.0 KB  |  177 lines

  1. /* This C program, h-demo.c, when compiled and linked with GNU libplot,
  2.    will emit to standard output a sample page illustrating many of the
  3.    Hershey fonts.  The file will be in portable metafile format.  It may be
  4.    translated to other formats, or viewed in an X window, with the `plot'
  5.    utility.  The sample page is taken from Allen Hershey's 1972 article in
  6.    Computer Graphics and Image Processing (vol. 1, no. 4, pp. 373-385).
  7.  
  8.    Compile and link with: 
  9.  
  10.        gcc h-demo.c -lplot -lXaw -lXmu -lXt -lXext -lX11 -lm
  11.  
  12.    or, in recent versions of the X Window System,
  13.  
  14.        gcc h-demo.c -lplot -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11 -lm
  15.  
  16.    To translate the sample page to Postscript, you would do 
  17.    `a.out | plot -T ps > page.ps'.  To display the page in an 
  18.    X Window, you would do `a.out | plot -T X', etc.  
  19.  
  20.    The above compilation instructions assume that your linker will be able
  21.    to find libplot and the X Window System libraries.  You may need to
  22.    include such options as -L/usr/local/lib and -L/usr/X11/lib to ensure
  23.    this.  Also, the linking options may differ if you are using Motif.
  24.    If you are using a C compiler other than gcc, consult your system
  25.    administrator.
  26.    
  27.    (The -DNO_CONST_SUPPORT option may need to be used if the C compiler,
  28.    like the version of `cc' supplied with SunOS 4.1.x, is so old that it
  29.    does not understand the `const' type qualifier.  If compiling under
  30.    SunOS 4.1.x, be sure also to specify the `-static' option to work around
  31.    problems with undefined symbols in the SunOS X libraries.)
  32.  
  33.    If you have any trouble running the demo after compiling it, be sure
  34.    your LD_LIBRARY_PATH environment variable includes the directory in
  35.    which libplot is stored.  This only applies on systems in which libplot
  36.    is implemented as a DLL, i.e. a shared library that is linked at 
  37.    run time. */
  38.  
  39. #include <stdio.h> 
  40. #include <plot.h>
  41.  
  42. #ifdef M_SQRT1_2
  43. #undef M_SQRT1_2
  44. #endif
  45. #define M_SQRT1_2   (0.70710678118654752440) /* 1/sqrt(2) */
  46.  
  47. #define NUM_DEMO_WORDS 34
  48. struct hershey_word 
  49. {
  50.   char *word;
  51.   char *fontname;
  52.   double m[6];
  53.   char just;
  54. };
  55.  
  56. #define CART (9.0/21.0)        /* `cartographic' size */
  57. #define INDEXICAL (13.0/21.0)    /* `indexical' size */
  58.  
  59. #define LLX -3800.0
  60. #define LLY -3450.0
  61. #define URX 3800.0
  62. #define URY 4150.0
  63.  
  64. #define BASE_FONTSIZE 220.0
  65.  
  66. struct hershey_word demo_word[NUM_DEMO_WORDS] = 
  67. {
  68.   {"Invitation", "HersheyScript-Bold", 
  69.      { 1., 0., 0., 1., -3125., 3980. }, 'l' },
  70.   {"ECONOMY", "HersheySans",           
  71.      { 1., 0., 0., 1., -3125., 3340. }, 'l'},
  72.   {"CARTOGRAPHY", "HersheySans",       
  73.      { CART, 0., 0., CART, -3125., 2700. }, 'l'},
  74.   {"Gramma", "HersheySerifSymbol",    
  75.      { 1., 0., 0., 1., -3125., 2060. }, 'l'},
  76.   {"\347\322\301\306\311\313\301", "HersheyCyrillic",       
  77.      { 1., 0., 0., 1., -3125., 1420. }, 'l'},
  78.  
  79.   {"COMMUNICATION", "HersheySans-Bold", 
  80.      { 1., 0., 0., 1., 0., 3980. }, 'c'},
  81.   {"VERSATILITY", "HersheySerif-Italic",
  82.      { 1., 0., 0., 1., 0., 3340. }, 'c'},
  83.   {"Standardization", "HersheySerif",   
  84.      { 1., 0., 0., 1., 0., 2700. }, 'c'},
  85.   {"Sumbolon", "HersheySerifSymbol",  
  86.      { INDEXICAL, 0., 0., INDEXICAL, 0., 2060. }, 'c'},
  87.   {"\363\354\357\366\356\357\363\364\370", "HersheyCyrillic",      
  88.      { 1., 0., 0., 1., 0., 1420. }, 'c'},
  89.  
  90.   {"Publication", "HersheyScript-Bold", 
  91.      { 1., 0., 0., 1., 3125., 3980. }, 'r'},
  92.   {"Quality", "HersheyGothicEnglish",  
  93.      { 1., 0., 0., 1., 3125., 3340. }, 'r'},
  94.   {"TYPOGRAPHY", "HersheySans",         
  95.      { CART, 0., 0., CART, 3125., 2700. }, 'r'},
  96.   {"AriJmo\\s-", "HersheySerifSymbol",    
  97.      { 1., 0., 0., 1., 3125., 2060. }, 'r'},
  98.   {"\346\317\316\305\324\311\313\301", "HersheyCyrillic",       
  99.      { 1., 0., 0., 1., 3125., 1420. }, 'r'},
  100.  
  101.   {"EXTENSION", "HersheySans", 
  102.      { 17./7., 0., 0., 2./7., 0., 780. }, 'c'},
  103.   {"CONDENSATION", "HersheySans", 
  104.      { 5./7., 0., 0., 17./7., 0., -20. }, 'c'},
  105.   {"Rotation", "HersheySans", 
  106.      { M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2, M_SQRT1_2, -2880., -20. }, 'l'},
  107.   {"ROTATION", "HersheySans", 
  108.      { M_SQRT1_2, -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, 2880., -20. }, 'r'},
  109.  
  110.   {"Syllabary", "HersheySerif",           
  111.      { 1., 0., 0., 1., -3125., -780. }, 'l'},
  112.   {"Art", "HersheyGothicEnglish",        
  113.      { 1., 0., 0., 1., -3125., -1420. }, 'l'},
  114.   {"Meteorology", "HersheySerif-Italic",  
  115.      { INDEXICAL, 0., 0., INDEXICAL, -3125., -2060.}, 'l'},
  116.   {"CHEMISTRY", "HersheySerif",           
  117.      { 1., 0., 0., 1., -3125., -2700.}, 'l'},
  118.   {"Analysis", "HersheySerif-BoldItalic", 
  119.      { 1., 0., 0., 1., -3125., -3340.}, 'l'},
  120.  
  121.   {"LEXIKON", "HersheySerifSymbol-Bold",      
  122.      { 1., 0., 0., 1., 0., -780.}, 'c'},
  123.   {"\\#N3719\\#N4724", "HersheySerif",      
  124.      { 1./.7, 0., 0., 1./.7, 0., -1420.}, 'c'},
  125.   {"Wissenschaft", "HersheyGothicGerman",
  126.      { 1., 0., 0., 1., 0., -2060.}, 'c'},
  127.   {"Electronics", "HersheySerif-Italic",  
  128.      { 1., 0., 0., 1., 0., -2700.}, 'c'},
  129.   {"COMPUTATION", "HersheySerif-Bold",    
  130.      { 1., 0., 0., 1., 0., -3340.}, 'c'},
  131.  
  132.   {"Alphabet", "HersheySerif",            
  133.      { 1., 0., 0., 1., 3125., -780.}, 'r'},
  134.   {"Music", "HersheyGothicItalian",      
  135.      { 1., 0., 0., 1., 3125., -1420.}, 'r'},
  136.   {"Astronomy", "HersheySerif",           
  137.      { INDEXICAL, 0., 0., INDEXICAL, 3125., -2060.}, 'r'},
  138.   {"MATHEMATICS", "HersheySerif",         
  139.      { 1., 0., 0., 1., 3125., -2700.}, 'r'},
  140.   {"Program", "HersheySerif-BoldItalic",  
  141.      { 1., 0., 0., 1., 3125., -3340.}, 'r'},
  142. };
  143.  
  144. int
  145. main()
  146. {
  147.   int handle, i;
  148.  
  149.   parampl ("META_PORTABLE", "yes");
  150.   handle = newpl ("meta", stdin, stdout, stderr);
  151.   selectpl (handle);
  152.  
  153.   openpl();
  154.   erase();
  155.   fspace (LLX, LLY, URX, URY);
  156.  
  157.   for (i = 0; i < NUM_DEMO_WORDS; i++)
  158.     {
  159.       savestate();
  160.       fontname (demo_word[i].fontname);
  161.       fconcat (demo_word[i].m[0], demo_word[i].m[1], 
  162.            demo_word[i].m[2], demo_word[i].m[3],
  163.            demo_word[i].m[4], demo_word[i].m[5]);
  164.       ffontsize (BASE_FONTSIZE);
  165.       fmove (0.0, 0.0);
  166.       alabel (demo_word[i].just, 'c', demo_word[i].word);
  167.       restorestate();
  168.     }
  169.  
  170.   closepl();
  171.  
  172.   selectpl (0);
  173.   deletepl (handle);
  174.  
  175.   return 0;
  176. }
  177.